<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	template="../templates/user_template.xhtml">

	<ui:define name="css-styles">
		<h:outputStylesheet library="css" name="admin-style.css" />
	</ui:define>

	<ui:define name="title">
			Админ панел
	</ui:define>

	<ui:define name="content">

		<h1 align="center" style="color: black;">Администраторски панел</h1>

		<h:form>
			<p>
				<h:outputLabel value="Потребителско име: "
					style="font-weight: bold; color: black;" />
				<h:inputText value="#{admin.username}" />
				<h:commandButton value="Търсене" />
			</p>
		</h:form>

		<h:outputText id="admin-username"
			rendered="#{! empty admin.username and !admin.isValidUsername()}">
			<h1 align="center" style="color: black;">Не е намерено
				потребителското име "#{admin.username}"</h1>
		</h:outputText>

		<h:panelGroup
			rendered="#{! empty admin.username and admin.isValidUsername()}">
			<h1></h1>

			<h:form>
				<table id="user" align="center">
					<tr>
						<td colspan="2" id="header-row-user">
							<h2>Информация за #{admin.username}</h2>
						</td>
					</tr>

					<tr class="odd-row">
						<th class="user-row-th">Потребителско име</th>
						<td class="user-row-td">#{admin.username}</td>
					</tr>

					<tr class="even-row">
						<th class="user-row-th">Email адрес</th>
						<td class="user-row-td">#{admin.email}</td>
					</tr>

					<tr class="even-row">
						<th class="user-row-th">Роля</th>
						<td class="user-row-td">#{admin.userRole}</td>
					</tr>

					<tr class="even-row">
						<th class="user-row-th">Нова роля</th>
						<td class="user-row-td">
							<h:selectOneMenu value="#{admin.newUserRole}">
								<f:selectItem itemValue="1" itemLabel="Потребител" />
								<f:selectItem itemValue="2" itemLabel="Персонал" />
								<f:selectItem itemValue="3" itemLabel="Администратор" />
							</h:selectOneMenu>
						</td>
					</tr>
				</table>

				<div align="center" style="margin-top: 10px">
					<h:commandButton value="Потвърди промяната"
						action="#{admin.changeRole()}" />
				</div>
				<div align="center" style="margin-top: 10px">
					<h:outputText value="#{admin.message}" styleClass="message" />
					<h:outputText value="#{admin.error}" styleClass="error" />
				</div>

			</h:form>
		</h:panelGroup>

	</ui:define>
</ui:composition>